import EventEmitter from "events";
export class SelectionModel extends EventEmitter {
    textModel_;
    selection_;
    constructor(textModel) {
        super()
        this.textModel_ = textModel
        this.selection_ = { anchor: 0, focus: 0 }
    }
    getSelection () {
        return { ...this.selection_ }
    }
    setSelection (selection) {
        if (selection && this.selection_ && selection.anchor === this.selection_.anchor && selection.focus === this.selection_.focus) {
            return
        }
        this.selection_ = selection ? { ...selection } : null
    }

    isCollapsed () {
        return this.selection_ && this.selection_.anchor === this.selection_.focus
    }

    isBackward () {
        return this.selection_ && this.selection_.anchor > this.selection_.focus
    }
}
export default SelectionModel;